<?php
namespace PsiFramework\Classes\Util\Database\Query;

use \PsiFramework\Classes\Util\Database\Query\SqlJoinClause;
use \PsiFramework\Classes\Util\Database\Query\SqlTable;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The SqlJoin class allows to represent a sql join
 *
 * @package classes.util.xpersist.sql
 */
class SqlJoin
{

    public static /*string*/ $full = "FULL" ;
    public static /*string*/ $left = "LEFT" ;
    public static /*string*/ $right = "RIGHT" ;

    protected /*SqlTable*/      $_table ;
    protected /*SqlJoinClause*/ $_joinClause ;
    protected /*string*/        $_joinType ;
    protected /*bool*/          $_inner ;

    /**
     * SqlJoin constructor
     *
     * @param $table        the table for the join
     * @param $joinClause    the clause for the join
     * @param $joinType        the type of the join
     * @param $inner        is it a inner join ?
     */
    public function __construct(
        SqlTable      $table,
        SqlJoinClause $joinClause=null,
        /*string*/    $joinType = "LEFT",
        /*bool*/      $inner=true
    )
    {
        $this->_table = $table ;
        $this->_joinClause = $joinClause ;
        $this->_joinType = $joinType ;
        $this->_inner = $inner ;
    }

    /**
     * Getter for the member variable $table
     *
     * @return SqlTable
     */
    public function getTable()
    {
        return $this->_table ;
    }

    /**
     * Getter for the member variable $joinClause
     *
     * @return SqlJoinClause
     */
    public function getJoinClause()
    {
        return $this->_joinClause ;
    }

    /**
     * Getter for the member variable $joinType
     *
     * @return string
     */
    public function getJoinType()
    {
        return $this->_joinType ;
    }

    /**
     * Getter for the member variable $inner
     *
     * @return bool
     */
    public function isInner()
    {
        return $this->_inner ;
    }

    /**
     * Setter for the member variable $table
     */
    public function setTable(SqlTable $table)
    {
        return $this->_table = $table;
    }

    /**
     * Setter for the member variable $joinClause
     */
    public function setJoinClause(SqlJoinClause $joinClause)
    {
        return $this->_joinClause = $joinClause;
    }

    /**
     * Setter for the member variable $joinType
     */
    public function setJoinType(/*string*/ $joinType)
    {
        return $this->_joinType = $joinType;
    }

    /**
     * Setter for the member variable $inner
     */
    public function setInner(/*bool*/ $inner)
    {
        return $this->_inner = $inner;
    }
}

